#include<iostream>
#include<map>
using namespace std;

int main(){
	freopen("input.txt", "r",stdin);
	map<int, int> m;
	int n;
	cin>>n;
	while(n--){
		int number,grade;
		cin>>number>>grade;
		m[number]+=grade;
	}
	int max_i=0,max_g=0;
	for(auto i:m){
		if(i.second>=max_g){
			max_g=i.second;
			max_i=i.first;
		}

	}
	cout<<max_i<<" "<<max_g;

}